#! /bin/bash
# Web build

# Build start.
start=$(date +%s)
echo "Start build."

if [ -z ${built_folder} ]; then
    source version.sh
    built_folder="wpbuilt"
    # built_folder=${tagdate}
fi

# Sass build
grunt compass:dev

# Requirejs build task.
# node web/tools/r.js -o web/tools/build.js dir=web/built/${built_folder}
# Webpack build task.
# Dev
webpack --progress --output-path=web/built/${built_folder}/ --output-public-path=/built/${built_folder}/
# Prod
# webpack -p --output-path=web/built/${built_folder}/ --output-public-path=/built/${built_folder}/

# Grunt task.
# Install node modules
# npm install
# Run grunt task.
# Uglify scripts
grunt uglify --path=web/built/${built_folder}
# Minified styles
grunt cssmin --path=web/built/${built_folder}
# Minified images
grunt imagemin --path=web/built/${built_folder}

echo "Build end."
end=$(date +%s) 

time=$(($end - $start))  
echo "Web built exec: "$time"s."

# Build end.
